import { createRequest } from '/@/api/service';
const module = 'ib/dingtalk/v1/ddUser';

/**
 * @function 钉钉用户登陆
 * @param data
 * @param header
 * @returns {Promise}
 */
function DD_USER_LOGIN(
  data: DingTalkUserApi.DDUserLoginReq,
  header: object = {},
): Promise<DingTalkUserApi.DDUserLoginResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/ddUserLogin`, data, header, 'POST');
}

/**
 * @function 钉钉token获取
 * @param data
 * @param header
 * @returns {Promise}
 */
function DD_TOKEN_GET(
  data: DingTalkUserApi.DDTokenGetReq,
  header: object = {},
): Promise<DingTalkUserApi.DDTokenGetResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/ddTokenGet`, data, header, 'POST');
}

/**
 * @function 下载用户上传的媒体文件
 * @param data
 * @param header
 * @returns {Promise}
 */
function DOWNLOAD_MEDIA(
  data: DingTalkUserApi.DownloadMediaReq,
  header: object = {},
): Promise<DingTalkUserApi.DownloadMediaResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/downloadMedia`, data, header, 'POST');
}

export { DD_USER_LOGIN, DD_TOKEN_GET, DOWNLOAD_MEDIA };
